package com.springcloud.controller;

import com.springcloud.dto.WebResultDto;
import com.springcloud.model.SysLogModel;
import com.springcloud.service.LogShowService;
import com.springcloud.utils.ListUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@Slf4j
public class TaskLogController {
    @Resource
    private LogShowService service;

    @PostMapping("/showLog")
    public WebResultDto showLog() {
        WebResultDto dto = new WebResultDto();
        List<SysLogModel> sysLogs = ListUtil.reverseList(service.showLog());
        dto.success(sysLogs);
        return dto;
    }
    @PostMapping("/queryLogs")
    public WebResultDto queryLogs(@RequestBody SysLogModel model) {
        WebResultDto dto = new WebResultDto();
        dto.success( service.selectLogs(model));
        return dto;
    }
}
